﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Role_Edit.aspx.cs" Inherits="SysManage_Role_Edit" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>角色编辑</title>
    <base target ="_self" />
    <link rel="stylesheet" href ="../css/css.css" type="text/css" />
    <!--#include file="../JS/KeyControlCode.js"-->
    <!--#include file="../JS/TrimData.js"--> 
    <script language ="javascript" type ="text/javascript" >
    <!--
        function ccc()
        {
            //alert(form1.RoleCode.value);
            var sFeatures = "dialogHeight:600px;dialogWidth:400px;resizeable:no;help:no;status:no";
            var sRoleCode = form1.RoleCode.value;
            eval("showModalDialog(\"Role_User_Index.aspx?RoleCode=\"+sRoleCode,window,sFeatures)");
        }
        
        
      //选择用户
      var sChoiceID;               //所在赋值的关键字
      var ChoiceNameInfo;          //选择的名称集合
      var ChoiceIDInfo;            //选择的ID集合
      var iChoicePoNumber1 =0;     //0表示任意多,其它的正整数为可以选择的最大个数.不可以为负数
      function GetMyUserTree(obj)
      {
         var sFeatures = "dialogHeight:600px;dialogWidth:400px;resizeable:no;help:no;status:no";
         var obj = showModalDialog("../SysManage/ChoiceUserInfo.aspx?ChoiceID="+obj+"&OrgType=2&OrgIDCol=0",window,sFeatures);
         if(obj != undefined)
         {
             sChoiceID = obj.sChoiceID;
             ChoiceNameInfo = obj.ChoiceNameInfo;
             ChoiceIDInfo=obj.ChoiceIDInfo;
             eval("form1.ChoiceName_"+sChoiceID+".value="+ChoiceNameInfo+";");
             eval("form1.HChoiceID_"+sChoiceID+".value="+ChoiceIDInfo+";"); 
             eval("form1.ChoiceName_"+sChoiceID+".blur()");
         }
      }
    -->
    </script>
</head>
<body style =" background-image :url('../images/hit_bg.gif');">
<% 
  Response .ExpiresAbsolute=System.DateTime.Now. AddSeconds(-1);
  Response.Expires=0;
  Response.CacheControl = "no-cache";
%>
    <form id="form1" method ="post" runat="server">
    <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="15%" height="18" valign="top" background="../images/tablelb.gif" class="font13"> 
      <div align="left"><img height="18" src="../images/tablelbleft.gif" width="18" alt ="" /></div></td>
    <td width="2%" valign="top" background="../images/tablelb.gif" bgcolor="#ffffff" class="font13"> 
      <div align="right"><img height="18" src="../images/tablelbright.gif" width="12" alt ="" /></div></td>
    <td colspan="2" align="center" bgcolor="#ffffff" class="font13"> <div align="right"> 
      </div></td>
  </tr>
  <tr> 
    <td height="26" colspan="2" align="center" bgcolor="#e9ecf5" class="font13"> 
      <div align="center">角色管理</div></td>
    <td width="80%" height="26" valign="bottom" background="../images/tddi.gif" class="font13"> 
      <div align="right"> </div></td>
    <td width="3%" valign="top" background="../images/tddi.gif" class="font13"> 
      <div align="right"><img height="26" src="../images/tddir.gif" alt ="" /></div></td>
  </tr>
</table>
<table width="98%" height="107" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#e9ecf5">
  <tr> 
    <td height="147"  valign="top"> 
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="tablelsdi">
          <tr> 
            <td width="4%" background="../images/tablelb01.gif"><img src="../images/tablelb01-left.gif" width="21" height="22" alt ="" /></td>
            <td width="82%" background="../images/tablelb01.gif" class="font12w">角色编辑</td>
            <td width="14%" background="../images/tablelb01.gif"> <div align="right"><img src="../images/tablelb01-right.gif" width="21" height="22" alt ="" /></div></td>
          </tr>
        </table>
        <input type="hidden" id="PCount" />
          <input type="hidden" id="BCount" />
          <input type="hidden" id="FECount" runat ="server"  />
          <input type="hidden" id="HFEList" runat ="server"  />
          <input type="hidden" id="OrRoleCode" runat ="server" />
          <input type="hidden" id="OrRoleName" runat ="server" />
          <input type="hidden" id="hidPageIDList" runat ="server"  />
          <input type="hidden" id="hidBtnIDList" runat ="server"  />
          <input type="hidden" id="hidEditType" runat ="server" />
    <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="tablelb">
      <tr>
        <td width="10%" bgcolor="#E1EEFD" class="tableleft" align ="right" >角色代码&nbsp;</td>
         <td bgcolor="#E1EEFD" class="tableleft"><asp:TextBox ID="RoleCode" runat ="server" TabIndex ="1" MaxLength ="20" onkeydown = "Number(this)" ></asp:TextBox><asp:Label ID="tishi1" runat ="server" Text ="*" ForeColor="Red"></asp:Label></td>
      </tr>
      <tr>
        <td bgcolor="#ECF4FD" class="tableleft"  align ="right">角色名称&nbsp;</td>
        <td bgcolor="#ECF4FD" class="tableleft"><asp:TextBox ID="RoleName" runat ="server" TabIndex ="2" MaxLength ="20"></asp:TextBox><asp:Label ID="tishi2" runat ="server" Text ="*" ForeColor="Red"></asp:Label></td>
      </tr>
      <tr>
        <td bgcolor="#E1EEFD" class="tableleft" align ="right">角色描述&nbsp;</td><td bgcolor="#E1EEFD" class="tableleft"><asp:TextBox ID="RoleDescr" runat ="server" TabIndex ="3" TextMode ="multiLine" Rows ="3" Columns ="40"></asp:TextBox>*描述小于200字</td>
      </tr>
      <tr>
        <td bgcolor="#E1EEFD" class="tableleft" align ="right">可访问文档类型&nbsp;</td>
        <td bgcolor="#E1EEFD" class="tableleft"><%=sFEHtml%></td>
      </tr>
      <tr>
        <td bgcolor="#ECF4FD" class="tableleft" align ="right">对应用户&nbsp;</td>
        <td bgcolor="#ECF4FD" class="tableleft">
             <asp:TextBox ID="ChoiceName_1" runat ="server" onclick ="GetMyUserTree(1)" TabIndex ="1" Width="300px" ></asp:TextBox>
             <input type="hidden" id="HChoiceID_1" runat ="server" />
             <input name="DisplayUser" id="btn_export" type="button" class="botton04"  onclick= "ccc()" value="显示用户" />
        </td>
      </tr>
      <tr>
        <td bgcolor="#E1EEFD" class="tableleft"  align ="right">是否有效&nbsp;</td>
        <td bgcolor="#E1EEFD" class="tableleft">
           <asp:dropdownlist id="Effective" tabIndex="4" runat="server" Enabled="true" Width="60px">			
			 <asp:ListItem Value="1" Selected ="true" >是</asp:ListItem>
			 <asp:ListItem Value="0">否</asp:ListItem>
		  </asp:dropdownlist>
        </td>
      </tr>
      <tr style ="height :30px;">
        <td bgcolor="#ECF4FD" class="tableleft" align ="center" colspan ="2">
            <asp:Button ID="SaveInfo" runat="server" Text="Button" Width="0px" Height="0px" OnClick="SaveInfo_Click" />
            <input id="GrantBtn1" type="button" runat ="server"  class="button02"  value ="提交(s)" accesskey ="s"  onclick ="SaveAllInfo()" /> &nbsp;&nbsp;
            <input type ="button" id="backBtn" value ="返回(c)" accesskey ="c"   class="button02" onclick ="window.close();" />
       </td>
      </tr>
      <tr>
        <td valign ="top" bgcolor="#E1EEFD" class="tableleft" align ="right">&nbsp;&nbsp;&nbsp;&nbsp;授权项&nbsp;</td><td bgcolor="#E1EEFD" class="tableleft"><%=sHtml%></td>
      </tr>
      </table>
      </td>
      </tr>
      </table>    
    </form>
    <script language ="javascript" type="text/javascript" >
    <!--      
      var sData = dialogArguments;
      form1.hidEditType.value = sData.stype ;
      if(sData.stype == "2")  // 2 修改 1 新建
      {
        window.document.all.DisplayUser.style.display= "";   
        var sobj = sData.RoleForm.Hcode.value;
        var ary=sobj.split('|'); 
        form1.RoleCode.value = trim(ary[0]);
        form1.OrRoleCode.value = trim(ary[0]);  //初始化时的角色代码

        form1.RoleName.value = trim(ary[1]);
        form1.OrRoleName.value = trim(ary[1]);   //初始化时的角色代码

        form1.RoleDescr.value = trim(ary[2]);
        form1.Effective.value = trim(ary[3]);
//        form1.ChoiceName_1.value = trim(ary[3]);
//        alert(ary);
        //选中已授权按钮  
        var sStr= trim(ary[4]);
        var ary=sStr.split('~');
        var nGrantCount=ary.length;  //授权个数
        var nPCount = form1.PCount.value;   //页面数

        var BtnCount = form1.BCount.value;  //按钮数
      
        for(j=0;j<nGrantCount-1;j++)  //总个数
        {
          var nary = ary[j];
          var ary1 = nary.split('.');  //第J个页面

          var GrantPageID = ary1[0];     //页面ID
          var GrantBtnID  = ary1[1];     //按钮ID集合
          //alert(sStr);
          //alert(nary);
          //alert(GrantPageID);
          //alert(GrantBtnID);
          for(i=0;i<nPCount;i++)         //页面授权信息
          {
            var sStr2 = form1.chkPage[i].value;
            //var ary2 = sStr2.split('^');
            if(GrantPageID==sStr2)
            {
              form1.chkPage[i].checked=true;
            }
          }
        
        
          var ary2 =GrantBtnID.split('^');
          var nGrantBtnID = ary2.length;     // //按钮授权信息
          for(l=0;l<nGrantBtnID-1;l++)
          {
             for(k=0;k<BtnCount;k++)          //总按钮数  
             {
               var sStr2 = form1.chkBtn[k].value;
               var ary3 = sStr2.split('.');
               if(ary2[l]==ary3[1] && GrantPageID == ary3[0])
               {
                 form1.chkBtn[k].checked=true;
               }
             }            
          }
        }
      }
      else
      {       
          window.document.all.DisplayUser.style.display= "none";   
      }   
      
      /////////////////////////////////////////////////////////////////////////////////
      
      function pageChkboxClick(obj)
      {
        //alert(form1.PCount.value);
        var PageCount = form1.PCount.value;
        var BtnCount = form1.BCount.value;
        var TheObj = obj.value;
        if(obj.checked)
        {
          if(PageCount == 1)  //只有一个页面时
          {
            if(form1.chkPage.value==TheObj)
              form1.chkPage.checked=true;
          }
          else   //多个页面时
          {
            for(i=0;i<PageCount;i++)
            {
              if(form1.chkPage[i].value==TheObj)
                form1.chkPage[i].checked=true;
            }
          }
          
          if(BtnCount == 1)  //只有一个按钮时
          {
            var sBtnChkboxValue=form1.chkBtn.value;
            var ary=sBtnChkboxValue.split('.');
            if(ary[0]==TheObj)
              form1.chkBtn.checked=true;
          }
          else  //多个按钮时
          {
            for(i=0;i<BtnCount;i++)
            {
              var sBtnChkboxValue=form1.chkBtn[i].value;
              var ary=sBtnChkboxValue.split('.');
              if(ary[0]==TheObj)
               form1.chkBtn[i].checked=true;          
            }
          }
        }
        else
        {
          if(PageCount == 1)  //只有一个页面时
          {
            if(form1.chkPage.value==TheObj)
              form1.chkPage.checked=false;
          }
          else   //多个页面时
          {
            for(i=0;i<PageCount;i++)
            {
              if(form1.chkPage[i].value==TheObj)
                form1.chkPage[i].checked=false;
            }
          }
          
          if(BtnCount == 1)  //只有一个按钮时
          {
            var sBtnChkboxValue=form1.chkBtn.value;
            var ary=sBtnChkboxValue.split('.');
            if(ary[0]==TheObj)
              form1.chkBtn.checked=false;
          }
          else  //多个按钮时
          {
            for(i=0;i<BtnCount;i++)
            {
              var sBtnChkboxValue=form1.chkBtn[i].value;
              var ary=sBtnChkboxValue.split('.');
              if(ary[0]==TheObj)
               form1.chkBtn[i].checked=false;
            }
          }
        }
        SavePageBtnInfo();
      }
      
      function btnChkboxClick(obj)
      {
        //alert(form1.BCount.value);
        var PageCount = form1.PCount.value;
        var BtnCount = form1.BCount.value;
        var TheObj=obj.value;
        var ary=TheObj.split('.');
        var sPageID=ary[0];
        if(obj.checked)
        {        
          if(PageCount == 1)  //只有一个页面时
          {
            if(form1.chkPage.value==sPageID && !form1.chkPage.checked)
            form1.chkPage.checked=true;
          }
          else   //多个页面时
          {
            for(i=0;i<PageCount;i++)
            {
              if(form1.chkPage[i].value==sPageID&&!form1.chkPage[i].checked)
                form1.chkPage[i].checked=true;
            }
          }
          
          if(BtnCount == 1)  //只有一个按钮时
          {
            if(form1.chkBtn.value==TheObj)
              form1.chkBtn.checked=true;
          }
          else  //多个按钮时
          {
            for(i=0;i<BtnCount;i++)
            {
              if(form1.chkBtn[i].value==TheObj)
              form1.chkBtn[i].checked=true;
            }
          }
        }
        SavePageBtnInfo();     
      }
      
      function SavePageBtnInfo()
      {
         var PageCount = form1.PCount.value;
         var BtnCount = form1.BCount.value;
         var sPageIDList = "";  //页面集合
         var sBtnIDList = "";   //按钮集合
         if(PageCount == 1)
         {
             if(form1.chkPage.checked)
             {
               var sPageID = form1.chkPage.value;
               sPageIDList = sPageIDList + sPageID + "^";
             }
             form1.hidPageIDList.value = sPageIDList;
         }
         else
         {
           for(i=0;i<PageCount;i++)
           {
             if(form1.chkPage[i].checked)
             {
               var sPageID=form1.chkPage[i].value;
               if(!isContained(sPageID,sPageIDList,"^"))
                 sPageIDList = sPageIDList + sPageID + "^";
              }
            }
            form1.hidPageIDList.value = sPageIDList;
         }
         
         if(BtnCount == 1)
         {
             if(form1.chkBtn.checked)
             {
               var sPageBtnID = form1.chkBtn.value;
               var ary = sPageBtnID.split('.');
               var sBtnID = ary[1];
               sBtnIDList = sBtnIDList + sPageBtnID + "^";
             }
             form1.hidBtnIDList.value = sBtnIDList;
         }
         else
         {
            for(i=0;i<BtnCount;i++)
            {
              if(form1.chkBtn[i].checked)
              {
                var sPageBtnID = form1.chkBtn[i].value;
                var ary = sPageBtnID.split('.');
                var sBtnID = ary[1];
                if(!isContained(sBtnID,sBtnIDList,"^"))
                  sBtnIDList = sBtnIDList + sPageBtnID + "^";
              }
            }
            form1.hidBtnIDList.value = sBtnIDList;
         }
         //alert(form1.hidBtnIDList.value+'*'+form1.hidBtnIDList.value)
      }
      
      function SaveAllInfo()
      {
          if(form1.RoleCode.value == "")
           {
               alert("角色代码不能为空");
               return;
           }
           if(form1.RoleName.value == "")
           {
               alert("角色名称不能为空");
               return;
           }
           if(form1.RoleDescr.value.length >200)
           {
               alert("角色描述不能超过200个字!");
               return;
           }           
           
                      //文档类型授权信息
           var SFECol = "";
           var iFECount = form1.FECount.value;
             if(iFECount == 1)
             {
                 if(form1.chkFileExtension.checked)
                 {
                   var sFEID = form1.chkFileExtension.value;
                   SFECol =  sFEID;
                 }
                 form1.HFEList.value = SFECol;
             }
             else
             {
                for(i=0;i<iFECount;i++)
                {
                  if(form1.chkFileExtension[i].checked)
                  {
                    var sFEID = form1.chkFileExtension[i].value;
                    if(SFECol == "")
                    {
                       SFECol =  sFEID;
                    }
                    else
                    {
                       SFECol += ","+sFEID;
                    }
                  }
                }
                form1.HFEList.value = SFECol;
             }
             
           SavePageBtnInfo();
           var ssave=window.document.getElementById("SaveInfo");
		   if(ssave!=null)
		      ssave.click();
      }
    -->
    </script>
</body>
</html>
